package com.github.shiqiyue.app.config.mybatis;

/***
 * mybatis plus 配置类
 * @author wenyao.wu
 * @date 2018/10/11
 */

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/***
 * mybatis plus 配置
 * @author wwy
 */
@Configuration
@MapperScan({"com.github.shiqiyue.app.modules.*.mapper"})
public class MybatisPlusConfiguration {

    /***
     * 自定义公共字段填充
     * @return
     */
    @Bean
    public MetaObjectHandler metaObjectHandler() {
        return new CustomMetaObjectHandler();
    }

    /**
     * 分页插件
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

    /***
     * 慢查询SQL打印
     * @return
     */
    @Bean
    public SlowSqlInterceptor slowSqlInterceptor() {
        SlowSqlInterceptor slowSqlInterceptor = new SlowSqlInterceptor();
        slowSqlInterceptor.setMaxTime(100L);
        return slowSqlInterceptor;
    }
}
